﻿@{
    Html.LOBHtmlHelper().SetLayout(this);
    Html.LOBHtmlHelper().SetMoreFunction(this, "{ text: '<span id=\"mnuModel\">Hàng mẫu</span>', encoded: false}, { text: '<span id=\"mnuBOM\">Định mức NVL</span>', encoded: false},{ text: '<span id=\"mnuPlan\">Kế hoạch sản xuất</span>', encoded: false}"); 
}
@{Html.RenderPartial("LinkPath");}

<div class="mtitle">
    @ViewBag.Title
</div>

@Html.LOBHtmlHelper().Busy("busyMain")

<table  cellpadding="1" cellspacing="1" style="table-layout:fixed;" width="100%">
    <tr>
        <td style="width: 100%;height:100%" valign="top">
            @Html.LOBHtmlHelper().GridView()
        </td>
    </tr>
</table>

<script type="text/javascript">

    var _codeBaseGrid = new CodeBaseGrid();
    $(document).ready(function () {
        _codeBaseGrid.Init(
            "grvtblSalesOrders",
            "SONo",
            "@Url.Action("View","SalesOrders")",
            "@Url.Action("Edit","SalesOrders")",
            "@Url.Action("Add","SalesOrders")",
            "@Url.Action("Delete","SalesOrders")",
            "@Url.Action("Save","SalesOrders")",
            "SR",
            "SR_tblSalesOrders",
            "rptSalesOrders"
            );
        _codeBaseGrid.SetWidthPupop(650);
        _codeBaseGrid.SetHeightPupop(370);
    });

    function View(addOnGrid) {
        _codeBaseGrid.View(addOnGrid);
    }

    function Add(addOnGrid) {
        _codeBaseGrid.Add(addOnGrid);
    }

    function Edit(addOnGrid) {
        _codeBaseGrid.Edit(addOnGrid);
    }

    function Delete(addOnGrid) {
        _codeBaseGrid.Delete(addOnGrid);
    }

    function Save() {
        _codeBaseGrid.Save();
    }

    function Undo() {
        _codeBaseGrid.Undo();
    }

    function Print()
    {
        var current = GetCurrentRow("grvtblSalesOrders");
        if (current != null) {
            var para = "SONo=" + current.SONo;
            _codeBaseGrid.PrintBy("AR", "SalesOrders", "rptSalesOrder", "Đơn đặt hàng", "SR_sprSalesOrders", para);
        }
    }

    function Copy(addOnGrid) {
        _codeBaseGrid.Copy(addOnGrid);
    }


    function MoreFunctionClick(id) {
       
            var current = GetCurrentRow("grvtblSalesOrders");

            if (current != null) 
            {
                    var url = "";
                    var model = null;
                    if (id == 'mnuModel') {
                        url = '@Html.BaseUrl()' + 'SalesOrders/ViewModel?SONo=' + current.SONo;
                        model = { displayMode: 0, id: "ARSS01", CustomName: "Hàng mẫu: " + current.SONo };


                        if (url != "" && !IsNull(window.parent) && !IsNull(window.parent._SelectFunction)) {
                            window.parent._SelectFunction(model, url);
                        }
                    }

                if (id == 'mnuPlan') {
                    url = '@Html.BaseUrl()' + 'StartStage?SONo=' + current.SONo;
                        model = { displayMode: 0, id: "ARTT02", CustomName: "Kế hoạch sản xuất: " + current.SONo };


                        if (url != "" && !IsNull(window.parent) && !IsNull(window.parent._SelectFunction)) {
                            window.parent._SelectFunction(model, url);
                        }
                    }
            }
        }
    

</script>
